<template>
	<view>
		<view style="margin-top: 30rpx;">
			<span style="color: #7d7d7d;margin-top: 20rpx;">订单编号:</span>{{orderId}}<br>
			<span style="display: inline-block;  color: #7d7d7d;margin-top: 20rpx;">订单金额:</span>{{castshoplist.price/100}}元
		</view>
		<view class="payfans">
			选择支付方式
			<view class="wx" style="margin-top: 50rpx;">
				<image style="width: 70rpx;height: 70rpx;" src="/static/icons/alipay.png"></image>
				支付宝支付

				<label class="radio" @tap="paytype='alipay'">
					<radio :checked="paytype=='alipay'" /></label>

			</view>
			<view class="wx" style="margin-top: 30rpx;">
				<image style="width: 70rpx;height: 70rpx;" src="/static/icons/wxpay.png"></image>
				微信支付
				<label class="radio" @tap="paytype='wxpay'">
					<radio :checked="paytype=='wxpay'" /></label>
			</view>
		</view>
		<view class="pay" @click="gopay">
			立即支付

		</view>
		<view class="tis">
			点击立即支付，即代表您同意<view class="terms">
				《条款协议》
			</view>
		</view>
	</view>
</template>

<script>
	import HomeApi from '@/api/mine/index.js'
	export default {
		data() {
			return {
				castshoplist: [],
				orderId: '',
				paytype: 'alipay',
				price:''
			};
		},
		methods: {
			gopay() {
				var parms = {
					userId: this.castshoplist.userId,
					orderId: this.orderId,
					payType: this.paytype
				}
				HomeApi.payConfirm(parms).then((res) => {
					if (res.data.code == 'S') {
                      uni.hideLoading();
                      uni.showToast({
                      	title:'支付成功'
                      });
					  setTimeout(()=>{
						  uni.redirectTo({
						      url: './payfinsh/payfinsh?price='+this.price
						  });
					  },2000)
					}else{
						uni.showToast({
							title:'支付失败'
						});
					}
				})

			}
		},
		onLoad(option) {

			this.orderId = option.id
		},
		created() {

			this.castshoplist = uni.getStorageSync('pay_shop');
			this.price=this.castshoplist.price
			console.log(this.castshoplist)
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f1ece7;
	}

	.wx {
		line-height: 70rpx;
		display: flex;
		justify-content: space-between;
	}

	.payfans {

		margin-top: 20rpx;
	}

	.pay {
		overflow: hidden;

		width: 500rpx;
		height: 100rpx;
		color: #fff;
		text-align: center;
		line-height: 100rpx;
		border-radius: 40rpx;
		background: #354e44;
		margin: 0 auto;
		margin-top: 150rpx;
	}

	.tis {
		margin-top: 10upx;
		width: 100%;
		font-size: 24upx;
		display: flex;
		justify-content: center;
		align-items: baseline;
		color: #999;

		.terms {
			color: #5a9ef7;
		}
	}
</style>
